package com.dinzeer.lostbladereborn.data;

import cn.mmf.slashblade_addon.data.SlashBladeAddonBuiltInRegistry;
import com.dinzeer.lostbladereborn.regsitry.LBRItemRegsitry;
import mods.flammpfeil.slashblade.data.builtin.SlashBladeBuiltInRegistry;
import mods.flammpfeil.slashblade.init.SBItems;
import mods.flammpfeil.slashblade.recipe.RequestDefinition;
import mods.flammpfeil.slashblade.recipe.SlashBladeIngredient;
import mods.flammpfeil.slashblade.recipe.SlashBladeShapedRecipeBuilder;
import mods.flammpfeil.slashblade.registry.slashblade.EnchantmentDefinition;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;

import java.util.function.Consumer;

import static com.dinzeer.lostbladereborn.data.LBRBuiltinRegsitry.getEnchantmentID;

public class LBRRecipeProvider extends RecipeProvider implements IConditionBuilder {
    public LBRRecipeProvider(PackOutput output) {
        super(output);
    }
    protected void buildRecipes(Consumer<FinishedRecipe> consumer){
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.tensazangetsu.location())
                .pattern("ABA")
                .pattern("BCB")
                .pattern("ADA")
                .define('A', Items.DIAMOND_BLOCK)
                .define('B', SBItems.proudsoul_trapezohedron)
                .define('C',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.zangetsu.location())
                                .killCount(2500)
                                .proudSoul(30000)
                                .refineCount(30)
                                .build()
                ))
                .define('D',SBItems.proudsoul_ingot)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.zangetsu.location())
                .pattern("ABA")
                .pattern("BCB")
                .pattern("ADA")
                .define('A', Items.DIAMOND_ORE)
                .define('B', SBItems.proudsoul_sphere)
                .define('C',SlashBladeIngredient.of(
                        SBItems.slashblade, RequestDefinition.Builder.newInstance()
                                .killCount(2000).refineCount(5).proudSoul(20000).build()
                ))
                .define('D',SBItems.proudsoul_ingot)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.frog.location())
                .pattern("ABA")
                .pattern("ECE")
                .pattern("ADA")
                .define('A', Items.GHAST_TEAR)
                .define('B', SBItems.proudsoul_sphere)
                .define('C',SlashBladeIngredient.of(
                        SBItems.slashblade, RequestDefinition.Builder.newInstance()
                                .refineCount(5).proudSoul(20000).build()
                ))
                .define('D',LBRItemRegsitry.ice_gem.get())
                .define('E',Items.ICE)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.crowbar.location())
                .pattern("ABA")
                .pattern("BCB")
                .pattern("DED")
                .define('A', Items.REDSTONE_BLOCK)
                .define('B', SBItems.proudsoul_sphere)
                .define('C',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SlashBladeAddonBuiltInRegistry.FLUORESCENT_BAR.location())
                                .proudSoul(1500)
                                .refineCount(10)
                                .killCount(1000)
                                .addEnchantment(new EnchantmentDefinition(getEnchantmentID(Enchantments.UNBREAKING), 3))
                                .build()
                ))
                .define('D',Items.OBSIDIAN)
                .define('E',Items.IRON_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.fish.location())
                .pattern("ABA")
                .pattern("CDC")
                .pattern("AEA")
                .define('A', Items.WATER_BUCKET)
                .define('B', SBItems.proudsoul_sphere)
                .define('C',Items.ICE)
                .define('D',SlashBladeIngredient.of(

                        SBItems.slashblade, RequestDefinition.Builder.newInstance()
                                .proudSoul(1500)
                                .refineCount(3)
                                .killCount(300)
                                .build()
                ))
                .define('E', LBRItemRegsitry.water_gem.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.undragon.location())
                .pattern("ABA")
                .pattern("CDC")
                .pattern("AEA")
                .define('A', LBRItemRegsitry.dragon_gem.get())
                .define('B', SBItems.proudsoul_sphere)
                .define('C',SlashBladeIngredient.of(

                        SBItems.slashblade_silverbamboo, RequestDefinition.Builder.newInstance()
                                .proudSoul(1500)
                                .refineCount(20)
                                .killCount(1000)
                                .build()
                ))
                .define('D',SlashBladeIngredient.of(

                        SBItems.slashblade, RequestDefinition.Builder.newInstance()
                                .proudSoul(500000)
                                .refineCount(30)
                                .killCount(3000)
                                .build()
                ))
                .define('E',Items.DRAGON_EGG)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Alkaid.location())
                .pattern("ABC")
                .pattern("BDB")
                .pattern("EBA")
                .define('A', SBItems.proudsoul_crystal)
                .define('B', SBItems.proudsoul_trapezohedron)
                .define('C',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('D',Items.EMERALD_BLOCK)
                .define('E',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Mizar.location())
                .pattern("AAB")
                .pattern("CDE")
                .pattern("AAB")
                .define('A', Items.LAPIS_BLOCK)
                .define('B', SBItems.proudsoul_crystal)
                .define('C',Items.DIAMOND_BLOCK)
                .define('D',Items.IRON_BLOCK)
                .define('E',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Fenrir.location())
                .pattern("ABA")
                .pattern("CDC")
                .pattern("CEC")
                .define('A', SBItems.proudsoul_crystal)
                .define('B',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('C',Items.SEA_LANTERN)
                .define('D', SBItems.proudsoul_trapezohedron)
                .define('E',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Megrez.location())
                .pattern("ABC")
                .pattern("BDB")
                .pattern("CBE")
                .define('A', Items.EXPERIENCE_BOTTLE)
                .define('D',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('C',SBItems.proudsoul_crystal)
                .define('B', Items.ICE)
                .define('E',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Phecda.location())
                .pattern("ABC")
                .pattern("BDB")
                .pattern("CBE")
                .define('A',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('D',Items.EMERALD_BLOCK)
                .define('C',SBItems.proudsoul_crystal)
                .define('B', Items.GOLD_BLOCK)
                .define('E',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Hagen.location())
                .pattern("ABB")
                .pattern("CDE")
                .pattern("ABB")
                .define('A',SBItems.proudsoul_crystal)
                .define('B',Items.GLOWSTONE)
                .define('C',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('D', Items.LAPIS_BLOCK)
                .define('E',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.Dubhe.location())
                .pattern("ABC")
                .pattern("BDB")
                .pattern("EBA")
                .define('A',SBItems.proudsoul_crystal)
                .define('B',Items.REDSTONE_BLOCK)
                .define('E', SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(LBRBuiltinRegsitry.White.location())
                                .killCount(1500)
                                .proudSoul(7300)
                                .refineCount(30)

                                .build()
                ))
                .define('D', Items.EMERALD_BLOCK)
                .define('C',Items.DIAMOND_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.White.location())
                .pattern("AAA")
                .pattern("ABA")
                .pattern("AAA")
                .define('A',SBItems.proudsoul_crystal)
                .define('B',SBItems.slashblade)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        ShapedRecipeBuilder.shaped(RecipeCategory.MISC,LBRItemRegsitry.ice_gem.get())
                .pattern(" A ")
                .pattern("ABA")
                .pattern(" A ")
                .define('A', SBItems.proudsoul)
                .define('B', Items.ICE)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        ShapedRecipeBuilder.shaped(RecipeCategory.MISC,LBRItemRegsitry.dragon_gem.get())
                .pattern(" A ")
                .pattern("ABA")
                .pattern(" A ")
                .define('A', SBItems.proudsoul)
                .define('B', Items.REDSTONE_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        ShapedRecipeBuilder.shaped(RecipeCategory.MISC,LBRItemRegsitry.water_gem.get())
                .pattern(" A ")
                .pattern("ABA")
                .pattern(" A ")
                .define('A', SBItems.proudsoul)
                .define('B', Items.WATER_BUCKET)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(LBRBuiltinRegsitry.administrator.location())
                .pattern("AAA")
                .pattern("BCB")
                .pattern("DED")
                .define('A', Items.NETHER_STAR)
                .define('B', SBItems.proudsoul_sphere)
                .define('C',SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SlashBladeAddonBuiltInRegistry.KIRISAYA.location())
                                .killCount(60000)
                                .proudSoul(550000)
                                .refineCount(100)
                                .build()
                ))
                .define('D',Items.LAPIS_BLOCK)
                .define('E',Items.DRAGON_EGG)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
    }
}
